package top.purity.server.user.domain;

import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.TenantId;
import top.purity.framework.orm.BaseDO;
import top.purity.framework.orm.BaseTenantDO;
import org.hibernate.annotations.ColumnDefault;

/**
 * @version 1.0
 * @Author Lmh
 * @Description
 * @CreateTime 2023-09-24 18:33
 */

@Data
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "user_account",
        uniqueConstraints = {
                @UniqueConstraint(columnNames = {"username", "tenant_id"})
        }, indexes = {
        @Index(name = "idx_un", columnList = "username"),
        @Index(name = "idx_nn", columnList = "nick_name"),
        @Index(name = "idx_ti", columnList = "tenant_id")
})
public class User extends BaseTenantDO {
    @Column(name = "username", nullable = false, length = 50)
    @Comment("账号")
    private String username;

    @Column(name = "password", nullable = false, length = 300)
    @Comment("密码，加密后的")
    private String password;

    @Column(name = "nick_name", nullable = false, length = 50)
    @Comment("昵称")
    private String nickName;

    @Column(name = "root_admin")
    @ColumnDefault("false")
    @Comment("是否为 root 管理员，true 是 false 否")
    private Boolean rootAdmin;

    @Column(name = "avatar", length = 500)
    @Comment("头像")
    private String avatar;

}
